<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layuiAdmin/layui/css/layui.css" media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>
    .margin-top {
      margin-top: 20px;
    }

    .h1 {
      font-size: 20px;
      /* padding-left: 50px; */
    }

    .layui-form-label {
      white-space: nowrap;
    }

    .height {
      height: 20px;
    }
  </style>
</head>


<body style="background-color: #fff;">

  <div class="layui-fluid">
    <div class="layui-card margin-top">
      <!-- layui-card-body -->
      <div class="">
        <form class="layui-form" action="">
          <!-- 行 -->
          <div class="layui-form-item">
            <div class="layui-inline">
              <label for="" class="layui-form-label">名称</label>
              <div class="layui-input-block" style="width:150px;">
                <input type="text" class="layui-input">
              </div>
            </div>
            <!--  -->

            <div class="layui-inline">
              <button type="button" class="layui-btn layui-btn-sm layui-btn-radius  layui-btn-normal">
                <i class="layui-icon">&#xe615;</i> 搜索
              </button>
            </div>
            <div class="layui-inline">
              <button type="button" class="layui-btn layui-btn-sm layui-btn-radius  layui-btn-warm">
                <i class="layui-icon">&#xe615;</i> 重置
              </button>
            </div>
          </div>

        </form>
      </div>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
  </div>

  <script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm  layui-btn-normal" lay-event="dttz"><i class='layui-icon'>&#xe624;</i>添加</button>
    <button class="layui-btn layui-btn-sm" lay-event="chakan"> <i class='layui-icon'>&#xe60b;</i>修改</button>
    <button class="layui-btn layui-btn-sm" lay-event="adminEdit"><i class='layui-icon'>&#xe615;</i>详情</button>
    <button class="layui-btn layui-btn-sm  layui-btn-danger" lay-event="adminDel"><i class='layui-icon'>&#xe669;</i>删除</button>

    <!--  <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button> -->
  </div>
</script>

  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">开始辨识</a>
    <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
    <a class="layui-btn layui-btn-xs" lay-event="del">结束辨识</a>
    <a class="layui-btn layui-btn-xs" lay-event="del">查看进度</a>
    <a class="layui-btn layui-btn-xs" lay-event="del">结束任务</a>
    <a class="layui-btn layui-btn-xs" lay-event="del">追加人员</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script>

  <script src="../../layuiAdmin/layui/layui.all.js" charset="utf-8"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

  <script>
    layui.use(['form', 'layedit', 'laydate', 'table'], function () {
      var table = layui.table
        , form = layui.form
        , layer = layui.layer
        , layedit = layui.layedit
        , laydate = layui.laydate;
      //日期
      laydate.render({
        elem: '#date'
      });
      laydate.render({
        elem: '#date1'
      });
      laydate.render({
        elem: '#date2'
      });
      table.render({
        elem: '#test'
        , url: '/js/table1.json'
        , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
        , title: '用户数据表'
        , data: [{}, {}, {}, {}]
        , cols: [[
          { type: 'checkbox', fixed: 'left' }
          , { field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true, hide: true }
          , { field: 'unit', title: '名称', fixed: 'left', unresize: true, sort: true }
          , { field: 'address', title: '内容概要 ', edit: 'text' }
          , { field: 'jc', title: '文件 ', align: 'center', }
          , { field: 'pj', title: '发布时间 ', }
          , { title: '操作 ', templet: '#barDemo', width: 500, align: 'center', }

        ]]
        , page: true
      });

      //头工具栏事件
      table.on('toolbar(test)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch (obj.event) {
          case 'zhuijiu':

            break;
          case 'exportFile':
            table.exportFile('test', checkStatus.data, 'xls'); //data 为该实例中的任意数量的数据
            break;

        };
      });

      //监听行工具事件
      table.on('tool(test)', function (obj) {
        var data = obj.data;
        //console.log(obj)
        if (obj.event === 'del') {
          layer.confirm('真的删除行么', function (index) {
            obj.del();
            layer.close(index);
          });
        } else if (obj.event === 'edit') {
          layer.prompt({
            formType: 2
            , value: data.email
          }, function (value, index) {
            obj.update({
              email: value
            });
            layer.close(index);
          });
        }
      });
    });
  </script>

</body>

</html>